package 笔试.美团;

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class 工人种树 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] worker = new int[n];
        for (int i = 0; i < n; i++) {
            worker[i] = in.nextInt();
        }
        int ans = solve(worker, n, k);
        System.out.println(ans);
    }

    private static int solve(int[] worker, int n, int k) {
        boolean[] visited = new boolean[200000];
        int sum = 0;
        for (int i = 0; i < k; i++) {
            for (int j = 0; j < n; j++) {
                if (!visited[worker[j] + i]) {
                    visited[worker[j] + i] = true;
                    sum++;
                    if (sum == k) {
                        return i + 1;
                    }
                }
            }
        }
        return 0;
    }
}